var {randomUtils, logUtils, timeUtils} = require ('../../utils/index');
var {Action} = require ('../../base/index');
var aWatchVideo = new Action ('看视频', {});
aWatchVideo.exec = function () {
  var baseSpan = 2;
  var span = randomUtils.getRandom (baseSpan, baseSpan + 3);
  logUtils.info ('将看视频' + span + '分钟');
  var startTime = Date.now ();
  var count = 0;
  while (true) {
    sleep (4 * 1000);
    count++;
    var hasExec = timeUtils.hasExec (startTime);
    if (count % 5 == 0) {
      logUtils.info ('已经看视频' + hasExec + '/' + span * 60);
    }
    if (hasExec > span * 60) {
      if (count % 5 != 0) {
        logUtils.info ('已经看视频' + hasExec + '/' + span * 60);
      }
      logUtils.info ('结束本轮看视频');
      break;
    }
  }
};

module.exports = aWatchVideo;
